﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter2.Section3
{
    public class Example07
    {
        public Example07()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            double[] x0 = { 3.0, 2.0, 0.0};

            V.Gradient obj = new V.Gradient(f, x0);
            obj.Compute();

            result += obj.Result[0].ToString() + "    ";
            result += obj.Result[1].ToString() + "    ";
            result += obj.Result[2].ToString() + "\r\n";

            result += (Math.Exp(x0[1])).ToString() + "    ";
            result += (x0[0]*Math.Exp(x0[1])).ToString() + "    ";
            result += (0.0).ToString() + "\r\n";          
        }
        private double func(double[] x)
        {
            return x[0]*Math.Exp(x[1]);
        }
    }
}
/* 
7.38905609893159    22.1671682967896    0
7.38905609893065    22.1671682967919    0
*/
